//
//  WorkHomeVC.m
//  XLDoctor
//
//  Created by longma on 2018/7/27.
//  Copyright © 2018年 XLH. All rights reserved.
//mj账户安全

#import "AccountSecurityVC.h"
#import "AllCountryCodeVC.h"
#import "PhoneNumberVC.h"
#import "SetLoginPasswordVC.h"
#import "ChangPasswordVC.h"
#import "ChangeEmailVC.h"
#import "ChangPhoneNumberVC.h"
#import "ChangEmailNumberVC.h"

@interface AccountSecurityVC ()
@property (weak, nonatomic) IBOutlet MJUICellImageTextView *regionItemView;
@property (weak, nonatomic) IBOutlet MJUICellImageTextView *passwordItemView;
@property (weak, nonatomic) IBOutlet MJUICellImageTextView *phoneItemView;
@property (weak, nonatomic) IBOutlet MJUICellImageBTextView *emailItemView;

@end

@implementation AccountSecurityVC


- (void)viewDidLoad {
    self.backgroundColorType = BackgroundColorTypeGray;
    [super viewDidLoad];
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    [self updateUI];
}

- (void)mj_setUI{
    [super mj_setUI];
    self.mj_titleLocalizable = @"Account Security";
}

- (void)updateUI {
    UserModel *userModel = UserManager.shared.userModel;
    NSString *countryName = userModel.area ? [HealthHelper getCountryNameWithCountryName:userModel.area] : [HealthHelper getCountryAreaName];
    self.regionItemView.subTitle = countryName;
    self.regionItemView.subTitleTextField.textColor = UIColor.mj_lightGrayColor;
    if(userModel.phoneNumber){
        self.phoneItemView.subTitle = [NSString stringWithFormat:@"+%@ %@",userModel.countryCode,userModel.phoneNumber.mj_securePhoneNumber];
    }
    if(userModel.email){
        self.emailItemView.subTitle = userModel.email;
    }
    self.passwordItemView.subTitleTextField.textColor = UIColor.mj_lightGrayColor;
    if(userModel.havePassword){
        self.passwordItemView.subTitle = MJUILocalizedString(@"Change");
    }else{
        self.passwordItemView.subTitlePlaceholder = @"";
    }
    
}

#pragma mark - 方法
- (IBAction)handleRegionButtonClick:(UIButton *)sender {
//    MJWeakSelf
//    AllCountryCodeVC *vc = [[AllCountryCodeVC alloc]init];
//    vc.handleCountryCodeBlock = ^(NSDictionary *countryAreaCode) {
//
//    };
//    [self.navigationController pushViewController:vc animated:true];
}

- (IBAction)handlePhoneButtonClick:(UIButton *)sender {
    
    
    NSString *phoneNumber = UserManager.shared.userModel.phoneNumber;
    if(phoneNumber){
        PhoneNumberVC *vc = [[PhoneNumberVC alloc]init];
        [self.navigationController pushViewController:vc animated:true];
    }else{
        ChangPhoneNumberVC *vc = [[ChangPhoneNumberVC alloc]init];
        [self.navigationController pushViewController:vc animated:true];
    }
}

- (IBAction)handleEmailButtonClick:(UIButton *)sender {
    
    NSString *email = UserManager.shared.userModel.email;
    if(email){
        ChangeEmailVC *vc = [[ChangeEmailVC alloc]init];
        [self.navigationController pushViewController:vc animated:true];
    }else{
        ChangEmailNumberVC *vc = [[ChangEmailNumberVC alloc]init];
        [self.navigationController pushViewController:vc animated:true];
    }
}

- (IBAction)handlePasswordButtonClick:(UIButton *)sender {
    
    if(UserManager.shared.userModel.havePassword){
        ChangPasswordVC *vc = [[ChangPasswordVC alloc]init];
        [self.navigationController pushViewController:vc animated:true];
    }else{
        SetLoginPasswordVC *vc = [[SetLoginPasswordVC alloc]init];
        [self.navigationController pushViewController:vc animated:true];
    }
}

- (void)requestData{
    
}

#pragma mark - 代理

#pragma mark - 懒加载

@end
